#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

int main() {
    char *peers_str = "12:123456234567";
    char str_ip[17], *ptr;
    int peers_str_len;
    int peer_ip, idx;
    short peer_port;

    sscanf(peers_str, "%d:", &peers_str_len);
    ptr = peers_str+3;
    for(idx = 0; idx < peers_str_len/6; ++idx) {
        peer_ip = ntohl((*(ptr+0) << 24) + (*(ptr+1) << 16) + (*(ptr+2) << 8) + (*(ptr+3)));
        peer_port = ntohs((*(ptr+4) << 8) + (*(ptr+5)));
        ptr += 6;
        sprintf(str_ip, "%d.%d.%d.%d", (peer_ip >> 24) & 0xFF, (peer_ip >> 16) & 0xFF, (peer_ip >> 8) & 0xFF, (peer_ip) & 0xFF);
        printf("peer%d: %s %u\n", idx, str_ip, peer_port);
    }
    return 0;
}
